#include<unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include<iostream>
#include<errno.h>
#include<string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include"comm.hpp"
using namespace std;

int main()
{
    int n = mkfifo(pathname,0666);
    if(n < 0)
    {
        cout << "make fifo false : " << strerror(errno) << endl;
    }

    int fd = open(pathname,O_RDONLY);
    char buff[1024];
    while(true)
    {
        int n = read(fd,buff,sizeof(buff)-1);
        if(n <= 0)
        {
            break;
        }
        buff[n] = 0;
        cout << buff << endl;
        sleep(1);
    }
    cout << "service close----" << endl;
    unlink(pathname);

    return 0;
}
